﻿<UserControl x:Class="ProTemplate.UserControls.CustomControl.DocumentInputForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="900">
    <UserControl.Resources>
        <Style TargetType="TextBlock" x:Key="AddDeclarationLable">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="70" />
        </Style>

        <Style TargetType="TextBox" x:Key="AddDeclarationInputBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="380" />
        </Style>
        <Style TargetType="input:AutoCompleteBox" x:Key="AddDeclarationAutoCompleteBoxStyle">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="380" />
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <telerikGridView:RadGridView telerik:Theming.Theme="Office_Blue" Style="{StaticResource CommonRadGridView}" ShowGroupPanel="False"  SelectionMode="Single"
                                     ItemsSource="{Binding Path=Items, Source={StaticResource DeclarationDocumentViewModel}}" >
            <telerikGridView:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="序号" DataMemberBinding="{Binding Index}" IsFilterable="False" />
                <telerik:GridViewDataColumn Header="随附单证" DataMemberBinding="{Binding DocumentName}" IsFilterable="False" />
                <telerik:GridViewDataColumn Header="单证编号" DataMemberBinding="{Binding CertificateNumber}" IsFilterable="False" />
                <telerikGridView:GridViewDataColumn Header=""  IsReorderable="False" IsFilterable="False">
                    <telerikGridView:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <telerik:RadButton x:Name="btnEdit" Click="btnEdit_Click" IsEnabled="{Binding Index, Converter={StaticResource DataRowButtonIsEnabledConverter}}">
                                    <Image Source="/ProTemplate;component/Images/Icons/edit.png" ToolTipService.ToolTip="编辑" Style="{StaticResource ToolBarIconStyle}" />
                                </telerik:RadButton>
                                <telerik:RadButton x:Name="btnDelete" Margin="3,0" Click="btnDelete_Click" IsEnabled="{Binding Index, Converter={StaticResource DataRowButtonIsEnabledConverter}}">
                                    <Image Source="/ProTemplate;component/Images/Icons/delete.png" ToolTipService.ToolTip="删除" Style="{StaticResource ToolBarIconStyle}" />
                                </telerik:RadButton>
                            </StackPanel>
                        </DataTemplate>
                    </telerikGridView:GridViewDataColumn.CellTemplate>
                </telerikGridView:GridViewDataColumn>
            </telerikGridView:RadGridView.Columns>
        </telerikGridView:RadGridView>
        <StackPanel Orientation="Horizontal" Grid.Row="1">
            <TextBlock Text="随附单证：" Margin="0,0" Width="60" Style="{StaticResource AddDeclarationLable}" />
            <input:AutoCompleteBox x:Name="acbDocument" Text="{Binding DocumentName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True,UpdateSourceTrigger=Explicit}"
                                                   Style="{StaticResource AddDeclarationAutoCompleteBoxStyle}" FilterMode="None" Populating="acbDocument_Populating"  ValueMemberPath="Name" Width="180" >
                <input:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </input:AutoCompleteBox.ItemTemplate>
            </input:AutoCompleteBox>
            <TextBlock Text="单证编号：" Margin="15,0" Width="60" Style="{StaticResource AddDeclarationLable}" />
            <TextBox x:Name="tbCertificateNumber" Style="{StaticResource AddDeclarationInputBox}" Width="180" MaxLength="32" Text="{Binding CertificateNumber, ValidatesOnExceptions=True, NotifyOnValidationError=True,UpdateSourceTrigger=Explicit}" />
            <Button x:Name="btnAddDocument"  Width="55" VerticalAlignment="Center" Height="20" Margin="10,0" Content="添加" Click="btnAddDocument_Click" />
            <StackPanel x:Name="spUpdateDocument" Orientation="Horizontal" Visibility="Collapsed">
                <Button x:Name="btnUpdateDocument"  Width="55" VerticalAlignment="Center" Height="20" Margin="10,0" Content="更新" Click="btnUpdateDocument_Click"  />
                <Button x:Name="btnCancelDocument"  Width="55" VerticalAlignment="Center" Height="20" Content="取消" Click="btnCancelDocument_Click"  />
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
